import { expect } from 'chai';
import { ethers } from 'hardhat';
import { MochiCSSR } from '../src';
import { rlpDecode } from '../src/rlp-encoder';
import {
  utils,
  providers,
  Contract,
  Signer,
  BigNumber,
  constants,
} from 'ethers';
import 'dotenv/config';

const lastFork = BigInt(process.env.MAINNET_FORK_BLOCK);

// mainnet
const weth = '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2';
const wethFeed = '0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419';
const dai = '0x6b175474e89094c44da98b954eedeac495271d0f';
const daiFeed = '0xAed0c38402a5d19df6E4c03F4E2DceD6e29c1ee9';
const usdc = '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48';
const usdcFeed = '0x8fFfFfd4AfB6115b954Bd326cbe7B4BA576818f6';
//const yfi = '0xD533a949740bb3306d119CC777fa900bA034cd52'; //crv
const yfi = '0x62b9c7356a2dc64a1969e19c23e4f579f9810aa7'; //cvxcrv
//const yfi = '0x0bc529c00C6401aEF6D220BE8C6Ea1667F6Ad93e';
//const yfi = '0x408e41876cccdc0f92210600ef50372656052a38';
const duck = '0x92e187a03b6cd19cb6af293ba17f2745fd2357d5';

// rinkeby
//const weth = "0x6440703C65D2F9f1BfA174D6963e93DFae2F4FB9";
//const wethFeed = "0x8A753747A1Fa494EC906cE90E9f37563A8AF630e";
//const dai = "0xD381c0555F08987a610c91c46D628058CA4C1483";
//const daiFeed = "0x2bA49Aaa16E6afD2a993473cfB70Fa8559B523cF";
//const yfi = "0xa0De839F1B96B3efB93BDca65ae4Ec48a897c2E7";

describe('uniswapCssr', function () {
  let accounts: Signer[];

  let owned: Contract;
  let cssr: Contract;
  let uni: Contract;
  let sushi: Contract;
  let chainlink: Contract;
  let tokenAdapter: Contract;
  let uniLPAdapter: Contract;

  let owner: Signer;
  let alice: Signer;
  let bob: Signer;
  let charles: Signer;

  let sdk: MochiCSSR;

  async function routerUpdate(
    blockNumber: bigint,
    token: string,
  ) {
    const packedProof = await sdk.getProof(blockNumber, token);
    console.log(packedProof);
    await cssr.update(token, packedProof);
  }

  beforeEach(async function () {
    const MockOwnedFactory = await ethers.getContractFactory('MockOwned');
    owned = await MockOwnedFactory.deploy();
    const CssrFactory = await ethers.getContractFactory('MochiCSSRv0');
    cssr = await CssrFactory.deploy(owned.address);
    const UniFactory = await ethers.getContractFactory('UniswapV2CSSR');
    uni = await UniFactory.deploy('0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f');
    const SushiFactory = await ethers.getContractFactory('SushiswapV2CSSR');
    sushi = await SushiFactory.deploy('0xC0AEe478e3658e2610c5F7A4A2E1777cE9e4f2Ac');
    const ChainlinkFactory = await ethers.getContractFactory(
      'ChainlinkAdapterEth',
    );
    chainlink = await ChainlinkFactory.deploy(owned.address);
    const UniAdapterFactory = await ethers.getContractFactory(
      'UniswapV2TokenAdapter',
    );
    tokenAdapter = await UniAdapterFactory.deploy(
      owned.address,
      cssr.address,
      uni.address,
      sushi.address,
    );
    const UniLPAdapterFactory = await ethers.getContractFactory(
      'UniswapV2LPAdapter',
    );
    uniLPAdapter = await UniLPAdapterFactory.deploy(
      weth,
      "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f",
      cssr.address,
      uni.address,
    );
    await cssr.setBluechip([weth,dai]);
    await chainlink.setFeed([weth,dai], [wethFeed, daiFeed]);
    await cssr.setFiatPriceAdapter(chainlink.address);
    await cssr.listAdapter(tokenAdapter.address);
    await cssr.listAdapter(uniLPAdapter.address);
    await cssr.setDefaultPriceSource(tokenAdapter.address);
    await cssr.setDefaultLiquiditySource(tokenAdapter.address);
    await tokenAdapter.addKeyCurrency(dai);
    await tokenAdapter.setMinimumLiquidity('1000000');
    await tokenAdapter.addKeyCurrency(weth);
    const directProvider = new providers.JsonRpcProvider(
      process.env.MAINNET_RPC_URL,
    );
    sdk = new MochiCSSR(directProvider);
    const duckPair = await sdk.uni.getPair(duck, weth);
    const usdcPair = await sdk.uni.getPair(usdc, weth);
    await cssr.setPriceSource(uniLPAdapter.address, [duckPair, usdcPair]);
  });

  it.only('uniAdapter', async function () {
    //await routerUpdate(lastFork, yfi, weth);
    //await routerUpdate(lastFork, yfi, weth);
    await routerUpdate(lastFork, yfi);
    //2 less zeros in div for viewing 2 float points
 const proof = '0x000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000001b80000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000032000000000000000000000000000000000000000000000000000000000000011c0000000000000000000000000000000000000000000000000000000000000152000000000000000000000000000000000000000000000000000000000000018200000000000000000000000000000000000000000000000000000000000000224f90221a0a162b315a7d87bbf31b7046ce967b117ba0b44c89446793196347c4e362a76cba01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d4934794aee98861388af1d6323b95f78adf3dda102a276ca0d08d11554e6b6f65f4d0efeec59308fbe8608995937d1f22d0d498788d5fc803a0547990c76860ffe8540ff2cc5579ecdbef57faced539bff7e2e375cf2493ebaca0bcdbb0aa2a35c1ea4d91c512e67495ad3a8cd80fae21e38d2e141ca6f41593f0b9010001e5052281109a2b1cf80608c63c1b2561243184ee5c4256122962c3bd13aaa900440d80c0900180c142da502bed89103667ad87390abf1f53165c505ef72829440a94adc49d476e5ca2321cb21732b0c6992320ccf9d08492012603902718921c1534c14a264700000614c390240ad21912a7f4280004565c0cc059030a951c849ccd725e366e41e2d342d961ba58004d1618a3010f039c02a721d860131abe1a381418418a6d116e99549aed0590046a048a2f85c22921642e0a049aad1861a41423afa8232731e0b328034a0c4f601f148b453c2b065e43083583422ae0481d3bf5030a126045428db44e190504ccc4b9c042a14b9166476bc85550e33066871fcea70ca96a9183cb417f8401c9c36383c89a3b84615457a899d883010a08846765746888676f312e31362e34856c696e7578a0e08976f1169b5f24926294f5e94e67a4c669e48e0ad7dcc342cb12fce3ed0481884cae75aa4809f3e8850c5fba8da1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e7bf90e78f90211a0d925633a871bd803802af9e9615699d6ae4ded0e8e2f11a534fbce5d78979cfaa065e8a322ae16727a734508d0f637910d9f1aaf0ab291363db2625c03408c1d0ea0c0dba174e7ae3f47d80c4295864d3462ce935505e4fc55b8e30cb3e67c00825ba017778d2c1c0ad7684366377b58cb8ee2a3020378e7ed036cc2a90c6876dd1299a0cd2bc41b6a522b2d0ccefc37cae0c3bcf3573f559b4b38eb80848aad01403d3aa09a4a924af30e9c86bfb50cf81787a543ea19b07c479a1df5116d868187222a34a0151096661c8ed20fec64e85e4f7716258d151c0e3aafc69fc1650feeb4622940a0332641984e8025959472890222221fd05ea1c9dee49953e1713287816feabfb6a05430d7a439350f25f33726917b29924b6a96536aabe36936c46612f26db826aaa0a137df0702042cc078ddc35cf1eec95e8609327563b67cd641a0679c80d951b9a029e8414f7d2c0e3cf6821e6118f9d65995591e4b3cb64e42b90398dad9866d3ea081ad4b851caecde235ebf91e5bbcaa5389f273fd2da2f0cc4737337c33dc5991a0604467f156e21b21b5d141880693c3d7d4d8c8734ab14fc2262f5f4b7884b187a0fd5bbd2820c76f8306a36c6b458c1c586e784785a21575875f07b5b0adb53e56a01eebab6ea3102c0cc2a9be45f477b876e01ae397a65a47627c444cac53695332a0032dc51c2534a47b0fc17ca07fc6786c792894cbfd0ae0be0f3a650290d4062380f90211a06fc700820b8097b13e2617fdb3774383c3badb674bbe2b26d0c15c98bba7f502a059149c1dc2186a634e25b7a8750c00455c1c3fc00a9e013362a9efcd900eb331a07b9e8f98b450c1ecbe142afebe5c67b1f382251a7c0faff64fc69693c988e810a091004225810cc3a724d4f8328bd64a76181cb10ca6f6d69df367c9bd32a2d50ca092c8103cf8d8fa4a00d8b21e6b45e214a07cf8ddad029cca5509f1322a7d6599a037cd0d0977f47355b285ef519d86b22528b846fcf640139d47f47140583a288ba0039661a1b1920123068956a6b3679e79e1403cd0de9f45ff305605cde0ca13a1a064fa8bc682d5e960f137a6a6d21ea7d357e3ae99690e5b49c04b94a3cba4a3e9a06c949ba21c375464d6bbcfa036dd38b07a55ec94ffe0e4877ebc5bcd02faabc9a099155a34d68e154dd360713912099d9d19e7086197bd7e30dbd5b76db280a98aa0639585dea9e1b24aeb4df191db5eebaa84d2dcb1211d62aa5780bf5aa4e3988ca05650251058057fcf46a44c8bf746fee2745f9a4f25f055a1f151ac81e5b762b7a05ade4dfe20dd5f9dab92ba39e01ceb99dab282938bbfb8f91e78fe666a8b072ca004fdc95be39c43cf146c37bcc8da1e458ef63bbd2ce1bb9aa6e61680d60f27e4a04f3f82a5b16d5ed2c5893d84b8ab9d01a560df3ce1a4d302e541de9fdb51b9e3a097d7f29a9104d8180f722331e25c6c0b6daa5d0a22dda0f045618c9c57770c3780f90211a0997f8e50459377e77c3f5a11c9a7f3e83c55f985eebc5dd60f32ec6bef48a7cca0000955edb68c8d037cacef871d0681cc28bd43226955e421de9ce8329e1327f3a0847bf0cf14171ee4bb60315c448e450dd477dcbe60c25aaea0392c9818915daba0f18f63d4c22246c7e142665cb27f7af22aa06645a9782d5da49f305f03111464a0a1ea2fadb95cbe975f318906d73509ef4d2a0b2168b7749fd990d180886e64eda08ec4ab780902904bb5f3a5649dde6bc1f0f1532da9fa187c281f51349815e489a0d5ebbb47bec6b538c80b3463cecce0be5cbd8fa5ed385a26231e19bd37c25742a00788280139e4c2c6192d9339a1514aec62c51940e3d6334ef8e8504be8221e7ba0e3a51fffce4d57cf1eeabfcdf5bcadaea4a4238bb8847717f512fac20009753aa007637ac06078e6872cd0fbae598aa4baa8cdae73cd4af9c96450f17d1b89a683a02d14085ce574697676e3c50b531f24afe002c3fe3b572399274b229112954994a0f09c96a1c2b9e059abb6264a89d10afa0e27c3d67777ba439d168448e61364f6a07b3a7f63e57c82064848ebf4fce9586b5d4d0acfca2f9d059ed4e3c4ec37c839a0ab2efa06a1e7f3a50e570be09569f4b1509a3cbbe6f4b848d787b5820c758ee2a0beef0c3539756370c1ffe1cc562187690e81c8807ca51fd6303ed79f3ad9cd5fa0f9dd2948f40076f9c34cd762ff352d4eb14e0c38261d81a27b05f03244b86bc480f90211a0fc19c7ea2d8fe0c6d971c8e7350488fce003ab1f078773767dbe6d94a00debe7a03514e8267534ad27bc8468b11727f359a4f5d4e78045c0169695691cfb573daea0b105c516fc241a03a5a64758854607ca274ebf6b056a4825ca312b8262c8065ca0f0a473fde93ba05426611691e29a627e322b43cbf8d496416ac9cf8f8bfa4816a0f8a0822fde100428ae24cf05d66f28561ab7c781b8c3697e29264c81bdc700f6a05e0ee0d2216634543d334b5c6e33ec5bb1270bb35217ef8acdf37673f85eef73a051f14565711c1f1f2937160c56cd80c7ee3160798b4062b429b90c86ef3bd012a0caffc6966e4afbb586d567c185b7387a388e436a3597000813a033784b0f7a6da00fb8c0fc23d4913d6e9d232df2f9d8542af319a1c3fcab326dc47389a96af358a06b9cb5312e208e62c59dde47152cc61c4ecd28b72212b8388493ab2835dae89aa08a307ff13356b7d9f347e14570f2410833d86f4515b95c1742e86f8b7e662853a0fb4fde3046e318099e070fcf3dc95718227dfd6b2af42ebdadc101bd15256ceaa0a08916d9f7ce4f63e12d72f962e43f15244fac46c585b8a00268211d2313c295a0562f45532b2474298b65f52d360f2328a1b9d45c89821a32cea80abaf83ff4ffa02fe15fad68c00cabffc6d081a06c6e0749aff6da77fafd6b7877311d64eb8aada03825b3015771305845f487221856c4044b4acd197f33d2c266416637712cfe0e80f90211a085929a9ff1493fe5480739f653a2fb186efae3a148083d0d9c6d9e8b7a5f5ceaa048b015fc681b200627f97ac8df3421f30753727ab7465d7ee7d897c99b059fd5a0553a07bce2cd9dc763f5eefec22cfc58eb190ce69f53de8f8c5c5832c9b860f3a0f4b7f75043e6fb7ec0bf2dee6e59640a0122cc5047d576f1d6035ddc29b18e82a04bb51ba6b71a80e9eaeb30032f64f5d97b9f39eb3695e9400e3c9a9a54a835b4a01112afd077f1a9404d2b40d0de04bf4d6d5d2ac753bfc515216186571200df7fa028b906f0ee4614310e6ee165f3fedc677d74d07beebd693622e9b5c8099eb35ba037cf65b05f9a27e3ee0841918093d51dee753428db4a7aa77d5bea2494e24e2aa048428a747b54546756057caa2a282a9375734dd540f317baa26911ffd478341ba0dad7acd7115b2cd908d48d740ebba08bb5a62b09dbf5b86170cad09549adc254a06ad819cae1843a33e303f553fc7ced3c841ceac5f5dc39b43108b038179ac82aa079dc4a28680ca49a66bd94fe91af37e31589926d89a7b2f4ab06e98962c3ff50a0d82b440ada1a72f72ac94c8134a01fdaf3e33fefdf1a38af8cc877802cd48b32a09846eb047a54b4663667791d01dfc82516bae84c042a7951812ffa28ef7e9a18a0f65fd5a6c6b85e1e7aa3fb13b41dc3919d693665b11f612c77973fc36fb69c71a0f32c1246cef93cfdbcc864f8ee9b73563aa1873ea363df43098e82835b3fa5d080f90211a0062ef3671e11f8fcca21dd63af46bbdd74bb6c6b85d1fbbfe865410782c1a3f6a0259a1fc6908d6cf804d924c1ba69a983483c0fc2a291e085b1871d8b9b00efa4a04cdd2becae7699fd8a1bce5a6e2b7bc26c927cd7a2f37df9b416c69cef979f83a07a01a87316b01ae2ccdc8eb1e84a7c9fc41874aa57815311d89b5452690a8294a0571cd8492c0657653c52b49a4e8704999764030872848669c712529c6cc124f5a05d55842576943b38b0fceecaeda1fba125e005c3ff1eac28c5ec76045faac4a2a05f335cbc3008fa4da94e249afe125e1efeeb1932d75b565a97dfded1e3b465b1a03c7513058453cf1457f374db2c0633e77ba14878182095c867d05196f4103e8ca0b9249e4fa9de93e56bce63ebdb956d29c0584cdac1f03db81ab83a742ddd47a7a07a51ef4e77af2781ebce5fc2c4ad9b58bbfd3226c11abf044aa8ae37af0cce28a009aefa77b87302f24a5f57fb5984a9ce8b9127a94bda2930ca940a7e5830562da04b0440557cb108ef97216534804f0e0b1af9bfc0bfa11fbf99970c809c563472a0ffe62987f35bdfb5ac60ffab5aff8e399ab6773bb39c7019d167c84e08bf58a5a0e4d7d4fa6829c58bcd1d9fbe11ff3158c5db6d11d6c0e527a90a95cc5a6993a6a051f71de334a69e9df6610414f845b63a446cf143a35fcb8010437152c30875a9a0e8764bb47c97b36151cf6118a8bb8c2fc729a02ad116f43701afc73c3b7c310680f8d1a09ea057175ca3ecada561156243079a1e7ea6f6aa51d2f07a90286c7605a23ba880a0f3079b41289076c177f625c07b1056517fb3b9735261c1b4e1913a2e5b1db0ba8080a0a8d61efb7a09310d7c34a2c871033b747fc1aeab95960e3063b13bcace962b3980808080a02c5e55f33794fe5212c52b5c6d003c79d8ccce97e787601258e917b5e82b7e1ba09ac08c502e814e5b992e5656d6c24cb2703e970a0f7f9a08e6f46fe405e1d6b7a09ac835fe218b5cfa6a280aa8cdb776e6c425cd888066ab1199b76af35538c87d80808080f871a0e94bfe6c58bb578445a0a32277cdc986b5e484869b55c7e2b49e62276b4c500aa08141f2d6ab5f9ce8867fbe098facae820791f56b30da0e7346d7aeca95729f2680a09f70299ec669e67219472b289bd726607836b3db863f282ba80ad74ccc2226b680808080808080808080808080f85180808080808080a0a2d71cf89302143ba99e89a927891c35e4cfca9b2e515c631e5cebe17d9f8772a0807e10bde52e5700cf0fc9150447e884f4ecd3a01ec04ec936baab3cfeafa11f8080808080808080f8659c3d4a77f21e861dfc9d1cc2da71df0d6a3f02e3798c5c1531ca8d3da8b846f8440180a0e4a4c5b03ea8c13816b217078cb2e3a7e30638d1c05d7fe3127c911ced44fb54a0cd82e2d9daddbf51cbce8d5429a0996e16fc670c4056566f19cf8864ad45a7460000000000000000000000000000000000000000000000000000000000000000000000032ff9032cf90211a0d827e5fc120b1c4b69dfce0c0f12ba3ce384f07063956010f1c9804156456635a0e40951941db5a6be503b6e148fec663aada1f9f68ebe3b1511d6a4f47cc90358a0ebb5eb4ba344efdb205ccad47276b9a65ded2598583aa428ac7872d5df956ce2a051e031f252c0546f2089946ce219a52cddb39046c11cab49ebbbd927d26caa85a008eca6cd27c729145a41bd2f7e26c247f37cb5e68736e7dbf57e75a7400db094a016eec567bbe50098f6c680d9cb5794862b42fafc6b694732c0ffa5d274c22f75a04ea4782e27cd0d26f9ef98ec32d17198d85d09683713567aa42b9436f2693c74a0a9dbf69ffabce851e0f6da67737efec180d4c3ea0118ecb2b5af0cc9749fbba7a0bc20ef20f94f5fa5e63b21a144f63bf5fcd374ac32f31696a7f2d1c8fb48ecafa0497c1af2277e776288a93194e7252755eb1cc1f121bd9a83cc77a610ababbb19a051606bee09889dbc676dde6d94608f042eb89b910f59fe1375a847d7b2cd33a8a0aab8687a22d05ca99ea0106d3a3db164acb90d8383877e07fc14fbe50f8f8a5ea08f5c7a72e6b3ab81d894fbdd9c54aecbd66e76f298b3a335852b74f0500e2038a031588953b71bbd17d1b110b3b895148f383213e30cf8d5d5169ebe2f07c7b7bea09944bcc257f44feb9d787611ab7a9cb93c8b037f2e1ab333bac75024342032b3a05e3b7b6a92e4b647f53140fed45e36cb2f1280362586f22d174e472ff3b3a24780f8d1808080a0a1fcddb33a5014eb0a489f33304526b2d6ab678ac5cb57926c99a2e61e1f53ff80a00dd4c5753beb89a12cb040c1f381e993ffb6948639189f623a95bd078d89ba22a051db1f2d76905aa6f6ceb9849298d91a01311c195b1baa601832bac485db56cba021ee62a584cee310330e3c69490cde3bccbcb256961f32d1870151c6c2b8ffd88080808080a0365b22945b935a067ed376f3f21c0a99d6c6e29fed967e652bf5fc3826e49adfa066c88b1cfc3da9bf0036713ec9c246230362302a1c66588220576546226168138080f843a020f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee3a1a0615454fa000000000001d0b4d9e01d3b665e0000000008cdc2b3c325c6aff121000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002def902dbf90211a0d827e5fc120b1c4b69dfce0c0f12ba3ce384f07063956010f1c9804156456635a0e40951941db5a6be503b6e148fec663aada1f9f68ebe3b1511d6a4f47cc90358a0ebb5eb4ba344efdb205ccad47276b9a65ded2598583aa428ac7872d5df956ce2a051e031f252c0546f2089946ce219a52cddb39046c11cab49ebbbd927d26caa85a008eca6cd27c729145a41bd2f7e26c247f37cb5e68736e7dbf57e75a7400db094a016eec567bbe50098f6c680d9cb5794862b42fafc6b694732c0ffa5d274c22f75a04ea4782e27cd0d26f9ef98ec32d17198d85d09683713567aa42b9436f2693c74a0a9dbf69ffabce851e0f6da67737efec180d4c3ea0118ecb2b5af0cc9749fbba7a0bc20ef20f94f5fa5e63b21a144f63bf5fcd374ac32f31696a7f2d1c8fb48ecafa0497c1af2277e776288a93194e7252755eb1cc1f121bd9a83cc77a610ababbb19a051606bee09889dbc676dde6d94608f042eb89b910f59fe1375a847d7b2cd33a8a0aab8687a22d05ca99ea0106d3a3db164acb90d8383877e07fc14fbe50f8f8a5ea08f5c7a72e6b3ab81d894fbdd9c54aecbd66e76f298b3a335852b74f0500e2038a031588953b71bbd17d1b110b3b895148f383213e30cf8d5d5169ebe2f07c7b7bea09944bcc257f44feb9d787611ab7a9cb93c8b037f2e1ab333bac75024342032b3a05e3b7b6a92e4b647f53140fed45e36cb2f1280362586f22d174e472ff3b3a24780f8918080a0a35305639f143fb8b8704453905a8cbcf5259c441266937317597536425d9c1280a02111dfc5b0acc14a2bcc7dd910ebe5db652ba94519e73366abacf01ff372a00ba0e7195280673816c675f44c49554bb3404a314d0ad8535d5d0999c9a271baea778080808080808080a055fbcd60c395036d8376eb22a4ecbe8b1f043bc39e0c4aa36679b39007dc0d918080f3a0201540171b6c0c960b71a7020d9f60077f6af931a8bbf590da0223dacf75c7af91901fcdb8fe68932db2e0c530a00d53241800000000000000000000000000000000000000000000000000000000000000000321f9031ef90211a0d827e5fc120b1c4b69dfce0c0f12ba3ce384f07063956010f1c9804156456635a0e40951941db5a6be503b6e148fec663aada1f9f68ebe3b1511d6a4f47cc90358a0ebb5eb4ba344efdb205ccad47276b9a65ded2598583aa428ac7872d5df956ce2a051e031f252c0546f2089946ce219a52cddb39046c11cab49ebbbd927d26caa85a008eca6cd27c729145a41bd2f7e26c247f37cb5e68736e7dbf57e75a7400db094a016eec567bbe50098f6c680d9cb5794862b42fafc6b694732c0ffa5d274c22f75a04ea4782e27cd0d26f9ef98ec32d17198d85d09683713567aa42b9436f2693c74a0a9dbf69ffabce851e0f6da67737efec180d4c3ea0118ecb2b5af0cc9749fbba7a0bc20ef20f94f5fa5e63b21a144f63bf5fcd374ac32f31696a7f2d1c8fb48ecafa0497c1af2277e776288a93194e7252755eb1cc1f121bd9a83cc77a610ababbb19a051606bee09889dbc676dde6d94608f042eb89b910f59fe1375a847d7b2cd33a8a0aab8687a22d05ca99ea0106d3a3db164acb90d8383877e07fc14fbe50f8f8a5ea08f5c7a72e6b3ab81d894fbdd9c54aecbd66e76f298b3a335852b74f0500e2038a031588953b71bbd17d1b110b3b895148f383213e30cf8d5d5169ebe2f07c7b7bea09944bcc257f44feb9d787611ab7a9cb93c8b037f2e1ab333bac75024342032b3a05e3b7b6a92e4b647f53140fed45e36cb2f1280362586f22d174e472ff3b3a24780f8d180a0c84db621bd372b5026d302e56e3aeb78680b25e65ba0d8e539eb4bf8372ec877a08b32a71f7f10dd5f2e17282f04c3fec2ce1199be8992c44845854c766c3a73bc80a0b3949641c4dab622a6af46bbcf5eea10a62536aa5b0d825f64299801b1b446c980a07635cf10ede783614d4a03ef0f44695f8c6a67dbff100b586f86bf51eaa319fc80a0844884901b3179ead1febb185467fc279a540ff38f13f07164b680bef54b998580808080a092b82147e42176677cc7a7111f24c3c3e922ccc2ebcd56fbf3312d1940ff089e808080f6a0205a7bb8d6351c1cf70c95a316cc6a92839c986682d98bc35f958f4883f9d2a894930391e855f9b6a45eebf8208bb48221ff8b13a700000000000000000000000000000000000000000000000000000000000000';
    const debug = await cssr.update(yfi, proof);
    let res = await cssr.getPrice(yfi);
    console.log(
      res.numerator
        .mul(1000000000000000000n)
        .div(res.denominator)
        .div(10000000000000000n)
        .toString(),
    );
  });
  
  it('uniLPAdapter', async function () {
    await routerUpdate(lastFork, duck);
    await routerUpdate(lastFork, usdc);
    let pair = await sdk.uni.getPair(duck, weth);
    let res = await cssr.getPrice(pair);
    console.log(
      res.numerator
        .mul(1000000000000000000n)
        .div(res.denominator)
        .div(10000000000000000n)
        .toString(),
    );
    pair = await sdk.uni.getPair(usdc, weth);
    res = await cssr.getPrice(pair);
    console.log(
      res.numerator
        .mul(1000000000000000000n)
        .div(res.denominator)
        .div(10000000000000000n)
        .toString(),
    );
  });

  it('chainlinkAdapter', async function () {
    const eth_price = await cssr.getPrice(weth);
    console.log(
      eth_price.numerator
        .mul(1000000000000000000n)
        .div(eth_price.denominator)
        .div(10000000000000000n)
        .toString(),
    );
    const dai_price = await cssr.getPrice(dai);
    // div by 100 for precision
    console.log(
      dai_price.numerator
        .mul(1000000000000000000n)
        .div(dai_price.denominator)
        .div(10000000000000000n)
        .toString(),
    );
    await routerUpdate(lastFork, yfi);
    const yfi_price = await cssr.getPrice(yfi);
    await cssr.getLiquidity(yfi);
    console.log(
      yfi_price.numerator
        .mul(1000000000000000000n)
        .div(yfi_price.denominator)
        .div(10000000000000000n)
        .toString(),
    );
  });
});
